home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Media 22
/
PC MEDIA CD22.iso
/
share
/
prog
/
spm220e
/
testmodc.c
< prev
next >
Wrap
Text File
|
1995-09-01
|
3KB
|
108 lines
/*
╔═════════════════════════════════════════════════════════════════════════════╗
║ NAME : TESTMODC.C ║
║ FUNCTION : A simple demo. of how to use MODEM.C... ║
║ COPYRIGHT : HETRU Fabrice 1991-1995. ║
╚═════════════════════════════════════════════════════════════════════════════╝
*/
#include "modem.c"
#include <stdio.h>
#include <ctype.h>
#include <process.h>
#define Int1B 0x1B /* Interrupt to manage "Ctrl-Break". */
void interrupt (*OldIBreak) ();
void interrupt CtrlBreak()
{
}
int kb_hit()
{
inregs.h.ah = 1;
int86(0x16,&inregs,&outregs);
return( !(outregs.x.flags & 64) );
}
int get_clav()
{
int h,l;
if (kb_hit())
{
inregs.h.ah = 0;
int86(0x16,&inregs,&outregs);
l = outregs.h.al;
h = outregs.h.ah;
if (l==0) l = h+0x100;
return(l);
}
else return(0);
}
main()
{
unsigned int fmt;
unsigned int InBuffSz,OutBuffSz;
int car = ' ';
unsigned char cs;
unsigned int n;
unsigned char modsc;
int Curs_OFF = 0x0720;
printf("HAYES modem testing using the C interfacing.\n");
/* Set "CommPort" to the COM number to use (0 to 7) ! */
CommPort = 0;
if (Check_STARCOMM_Present()==0)
{
printf("Please, load STARCOMM.EXE...\n");
exit(1);
}
else printf("<I>nitialize <C>onnect <H>ang-off Q==>QUIT\n");
Init_status();
Init_Port('7','1','N',2400,&InBuffSz,&OutBuffSz);
Open_Port();
OldIBreak = getvect(Int1B);
setvect(Int1B,CtrlBreak);
Show_CorF = TRUE;
install_Clock();
while(car!='Q')
{
if (kb_hit())
{
car=toupper(get_clav());
switch(car)
{
case 'I': { CmdeToModem(InitMod,''); break; }
case 'C': { CmdeToModem(Connect,''); break; }
case 'H': { CmdeToModem(Raccroch,''); break; }
case 59: printf("<I>nitialize <C>onnect <H>ang-off Q==>QUIT\n");
}
}
if (CheckBufferIn(&n))
{
if (ReadSerie(&cs,1,&n)==0) printf("%c",cs);
}
}
un_install_Clock();
modsc = peekb(0x40,0x49);
if ( (modsc==2) | (modsc==3) | (modsc==7) )
movedata(FP_SEG(&Curs_OFF),FP_OFF(&Curs_OFF),seg_ecran,158,2);
else movedata(FP_SEG(&Curs_OFF),FP_OFF(&Curs_OFF),seg_ecran,76,2);
Reset_Init_status(Format);
if (wherex()>1) printf("\n");
if (Close_COMM(TRUE)!=0) printf("Port NOT closed !\n");
printf("Test has terminated.\n");
setvect(Int1B,OldIBreak);
}